package com.yinhd.study.customLog;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @program: study
 * @description:
 * @Author: yinhd
 * @create: 2022-02-09 10:21
 **/
@RestController
public class LogController {
    @Autowired
    LogDTO logmap;

    @GetMapping("/demo/customLog")
    @OperationLog(operator = "{{#name}}",action = "修改",heir = "字典项",content = "的{{#data[type]}}",state = "{{#resultCode==0?'成功':'失败'}}")
    public BaseGduiDTO<Map<String, String>> CustomLog(String id,String name,LogDTO logDTO ){
        try {
            BaseGduiDTO result = new BaseGduiDTO();
            Map map = new HashMap();
            map.put("type","资产编码");
            result.setResultMsg("成功").setData(map).setResultCode(0);
            /**
             * 字典项操作
             */
 //         throw new  Exception();
            return result;
        }catch (Exception e){
            return BaseGduiDTO.error();
        }
    }

    @GetMapping("/demo/customLogs")
    @OperationLog(operator = "{{#name}}",heir = "字典项",content = "的{{#data[type]}}",state = "{{#resultMsg.equals('11')?'成功':'失败'}}")
    public BaseGduiDTO CustomLogs(LogDTO logDTO,String name){
        BaseGduiDTO result = new BaseGduiDTO();
        Map map = new HashMap();
        map.put("type","资产编码");
        try {
            throw new Exception();
           // result.setResultMsg(null).setData(map).setResultCode(0);
            /**
             * 字典项操作
             */
            //         throw new  Exception();
           // return result;
        }catch (Exception e){
            return result.setData(map).setResultCode(1).setResultMsg("11");
        }
    }

}
